﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RAMED
{
    public partial class Dossier_incompletForm : Form
    {
        public Dossier_incompletForm()
        {
            InitializeComponent();
            RAMEDEntities1 context = SingletonContext.GetContext();
            comboBoxannexe.DataSource = context.Annexe_administratif;
            comboBoxannexe.DisplayMember = "nom_annexe_administratif";
        }

        private void Dossier_incompletForm_Load(object sender, EventArgs e)
        {

        }

        private void btnajouterincompler_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                RAMEDEntities1 Context = new RAMEDEntities1();
                Dossier_incomplet dossierajoute = new Dossier_incomplet();
                dossierajoute.num_dossier = utitlitaire.CasterString(txtnumdoss.Text);
                dossierajoute.champs_manquent = txtchamps.Text;
                dossierajoute.Nom = txtnom.Text;
                dossierajoute.Prenom = txtprenom.Text;
                dossierajoute.CIN = txtCIN.Text;
                dossierajoute.complet = false;

                dossierajoute.id_annexe_administratif = ((Annexe_administratif)comboBoxannexe.SelectedValue).id_annexe_administratif;
                dossierajoute.Nom = txtnom.Text;
                dossierajoute.CIN = txtCIN.Text;


                Context.Dossier_incomplet.AddObject(dossierajoute);
                Context.SaveChanges();
                this.Dispose();
            }

        }

        private void btnmodifierdemande_Click(object sender, EventArgs e)
        {

        }

        private void txtnumdoss_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtchamps_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void comboBoxannexe_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void Button1_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void txtnumdoss_Validating(object sender, CancelEventArgs e)
        {
            utitlitaire.ValiderNombre("Veuillez saisir un nombre valide", txtnumdoss, e, errorProvider1);
        }

        private void txtchamps_Validating(object sender, CancelEventArgs e)
        {
            utitlitaire.ValiderNombre("Veuillez saisir un Champs", txtnumdoss, e, errorProvider1);
        }
        private void Button21_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

        private void btnrechercherdossier_Click(object sender, EventArgs e)
        {
            RechercheDossierFormcs RDF = new RechercheDossierFormcs();
            RDF.Show();

        }

        private void txtchamps_Validating_1(object sender, CancelEventArgs e)
        {
            utitlitaire.ValiderChampsRecquit("le champs champs est obligatoire", txtchamps, e, errorProvider1);
        }

        private void txtnom_TextAlignChanged(object sender, EventArgs e)
        {

        }

        private void txtnom_Validating(object sender, CancelEventArgs e)
        {
            utitlitaire.ValiderChampsRecquit("le champs Nom est obligatoire", txtnom, e, errorProvider1);
        }

        private void txtCIN_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtCIN_Validating(object sender, CancelEventArgs e)
        {
            utitlitaire.ValiderChampsRecquit("le champs CIN est obligatoire", txtCIN, e, errorProvider1);
        }

        private void txtprenom_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtprenom_Validating(object sender, CancelEventArgs e)
        {
            utitlitaire.ValiderChampsRecquit("le champs prénom est obligatoire", txtprenom, e, errorProvider1);
        }
    }
}
